#! /bin/sh -vx
# $Id$
# Copyright 2017 Karl Berry <tex-live@tug.org>
# Copyright 2013, 2014 Peter Breitenlohner <tex-live@tug.org>
# You may freely use, modify and/or distribute this file.

BinDir=${BinDir:-.}
ExeExt=${ExeExt:-}
_xdvipdfmx=$BinDir/xdvipdfmx$ExeExt

TEXMFCNF=$srcdir/../kpathsea
TEXFONTMAPS="$srcdir/tests;$srcdir/data"
DVIPDFMXINPUTS="$srcdir/tests;$srcdir/data"
TEXPICTS=$srcdir/tests
TEXFONTS=$srcdir/tests
PKFONTS=$srcdir/tests
export TEXMFCNF TEXFONTMAPS DVIPDFMXINPUTS TEXPICTS TEXFONTS PKFONTS

failed=

echo "*** xdvipdfmx --version" \
	&& $_xdvipdfmx --version \
	&& echo && echo "xdvipdfmx-version tests OK" && echo \
	|| failed="$failed xdvipdfmx-version"

echo "*** xdvipdfmx --help" \
	&& $_xdvipdfmx --help \
	&& echo && echo "xdvipdfmx-help tests OK" && echo \
	|| failed="$failed xdvipdfmx-help"

echo "*** xdvipdfmx --showpaper" \
	&& $_xdvipdfmx --showpaper \
	&& echo && echo "xdvipdfmx-showpaper tests OK" && echo \
	|| failed="$failed xdvipdfmx-showpaper"

echo "*** xdvipdfmx -v -o image2.pdf image" && echo \
	&& $_xdvipdfmx -v -o image2.pdf $srcdir/tests/image \
	&& echo && echo "xdvipdfmx-image tests OK" && echo \
	|| failed="$failed xdvipdfmx-image"

echo "*** xdvipdfmx -v -o xbmc2.pdf xbmc" && echo \
	&& $_xdvipdfmx -v -o xbmc2.pdf  $srcdir/tests/xbmc \
	&& echo && echo "xdvipdfmx-xbmc tests OK" && echo \
	|| failed="$failed xdvipdfmx-xbmc"

test -z "$failed" && exit 0
echo
echo "failed tests:$failed"
exit 1
